<?php
Yii::app()->clientScript->registerScript(
        'myHideEffect', '$(".info").animate({opacity: 1.0}, 3000).fadeOut("slow");', CClientScript::POS_READY
);


$form = $this->beginWidget('CActiveForm', array(
            'id' => 'sys-admin-group-form',
            'enableAjaxValidation' => false,
));

?>
<div class="block">
    <div class="alert alert_grey">
        <img height="24" width="24" src="<?php echo Yii::app()->params['backendUrl']; ?>/images/icons/small/grey/alert_2.png">
        Fields with <span class="required"><strong>*</strong></span> are required.
    </div>

    <p class="note">Fields with <span class="required">*</span> are required.</p>

<?php if (Yii::app()->user->hasFlash('pesan')): ?>
        <div class="info">
        <?php echo Yii::app()->user->getFlash('pesan'); ?>
        </div>
        <?php endif; ?>

    <?php echo $form->errorSummary($model); ?>







    <div class="input_group">
<?php echo $form->labelEx($model, 'administrator_group_title'); ?>
<?php echo $form->textField($model, 'administrator_group_title', array('size' => 40, 'maxlength' => 100)); ?>
        <?php echo $form->error($model, 'administrator_group_title'); ?>
    </div>

    <div class="input_group">
<?php echo $form->labelEx($model, 'administrator_group_is_active'); ?>
<?php
echo $form->radioButtonList($model, 'administrator_group_is_active', array('0' => 'Tidak', '1' => 'Ya'), array('separator' => '&nbsp;&nbsp;&nbsp;', 'labelOptions' => array('style' => 'display:inline')));
?>
        <?php echo $form->error($model, 'administrator_group_is_active'); ?>
    </div>    
 

   </div>

<?php
        $this->widget('CTreeView', array(
            'data' => $data,
            'animated' => 'normal',
            'collapsed' => false,
            'htmlOptions' => array('class' => 'treeview-gray')));
        ?>
        <button class="button_colour round_all"><img height="24" width="24" alt="Bended Arrow Right" src="<?php echo Yii::app()->params['backendUrl']; ?>/images/icons/small/white/bended_arrow_right.png"><span><?php echo ($model->isNewRecord) ? 'Create' : 'Save'; ?></span></button>

<?php $this->endWidget(); ?>


<script type="text/javascript">
    $(document).ready(function(){
        $('#all').click(function() {
            var checked_status = this.checked;
            $(".parentCls").each(function(){
                //alert($(this).val());
                if ($('#all').is(':checked')) {
                    $(this).attr('checked', true);
                } else {
                    $(this).attr('checked', false);
                }
                
            });
            $(".childCls").each(function(){
                if ($('#all').is(':checked')) {
                    $(this).attr('checked', true);
                } else {
                    $(this).attr('checked', false);
                }
            });
        });
        
        $(".parentCls").each(function() {
            var idParent = $(this).attr('id');
            var idP = idParent.split("_");
            
            $('#'+idParent).click(function() {
                $('ul > li > .childCls').each(function() {                    
                    if ($('#'+idParent).is(':checked')) {
                        $('.child'+idP[1]).attr('checked', true);
                    } else {
                        $('.child'+idP[1]).attr('checked', false);
                    }
                });      
            });
            $('.child'+idP[1]).click(function() {
                if ($('.child'+idP[1]).is(':checked')) {
                    $('.parent'+idP[1]).attr('checked', true);
                } else {
                    $('.parent'+idP[1]).attr('checked', false);
                }
                
            });
            
            $('.child_action'+idP[1]).click(function(){
                if($('.child_action'+idP[1]).is(':checked')){
                    $('.child'+idP[1]).attr('checked',true);
                    $('.parent'+idP[1]).attr('checked',true);
                }
                else {
                    $('.child'+idP[1]).attr('checked',false);
                    $('.parent'+idP[1]).attr('checked',false);
                }
            });
        });
    })
</script>